< previous page page_319 next page >

Page 319
e10a6a0a59f035e870d90cca05b85fce.gif
    ' See how many rows and columns we will need.
    cols = Int(pic.ScaleWidth / wid + 1)
    rows = Int(pic.ScaleHeight / hgt + 1)

    ' Copy the tile.
    y = 0
    For r = 1 To rows
        x = 0
        For c = 1 To cols
            pic.PaintPicture tile_image.Picture, x, y
            x = x + wid
        Next c
        y = y + hgt
    Next r
End Sub
Example program Tile, shown in Figure 10.33, uses the subroutine TilePicture a variety of tiles. Click on a pattern to make the tile its drawing area with it.
Some tilings are easiest to define when you use nonrectangular tiles. For example, you can define the tile shown in Figure 10.34 using the hexagonal tile surrounded by bold lines. Covering an area using this tile is a bit more complicated than it is to use a rectangular tile for a couple reasons.
Rows and columns are harder to locate in this tiling than they are in a rectangular tiling. A copy of the tile in a row does not lie immediately next to the tiles on its left and right. A row does not lie directly below the row above.
To correctly place the tiles, you can pass parameters into the tiling routine indicating the X offset it should use between tiles on the same row and the X and Y offsets it should use between rows.
0319-01.jpg
Figure 10.33
Program Tile tiling a picture box.

 
< previous page page_319 next page >